import React from 'react';
import { connect } from 'react-redux';

import { Card, WingBlank } from 'antd-mobile';

import { getUserList } from '@/redux/modules/userInfo';

@connect(
    state => ({userList : state.user.userList}),
    { getUserList }
)
class Boss extends React.Component{
    componentDidMount(){
        this.props.getUserList({userType: 1});
    }
    render(){
        return (<div>
            <WingBlank>
                {
                    this.props.userList.map((item) => {
                        return (<Card key={item._id}>
                        {
                            item.tx ?
                            (<div onClick={() => {
                                this.props.history.push(`/dashboard/chat/${item._id}`);
                            }}><Card.Header
                                title={item.userName}
                                thumb={require(`@/component/avatarselector/img/${item.tx}.png`)}
                                extra={<span>{item.zw }</span>}
                            ></Card.Header><Card.Body>{item.jj.split('\n').map((v, i)=>{
                                return (<p key={i}>{v}<br />一个月{item.m}</p>);
                            })}</Card.Body></div>)
                            :
                            null
                        }
                        </Card>);
                    })
                }
            </WingBlank>
        </div>);
    }
}

export default Boss;